from django.db import models
from datetime import datetime
from django.utils.timezone import now

# Create your models here.


class BookBase(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=100, null=False)
    author = models.CharField(max_length=100, null=False)
    price = models.FloatField(default=0, null=False)
    # 指定名字

    class Meta:
        db_table = "book_base"


class Information(models.Model):
    # 自增长的int型 BigAutoField更大
    id = models.AutoField(primary_key=True)
    # Boolean
    adult = models.BooleanField(default=True, null=False)
    # CharField 需要给定最大长度, 如果超过用TextField
    add = models.CharField(max_length=100)
    # 时间
    born = models.DateTimeField(auto_now=True)
    # EmailField, 不必非要指定邮箱格式和Char一样
    email = models.EmailField(max_length=100)

    class Meta:
        db_table = "information"
        # 反向排序
        ordering = ['-id']
